<% unless attachment_collection.unused? %>
<div class="documents__dropdown-container">
  <button id="dropdown-documents-trigger-<%= attachment_collection.id %>" class="documents__collection-trigger" data-controller="dropdown" data-target="dropdown-menu-documents-<%= attachment_collection.id %>" aria-expanded="false">
   <div class="documents-details">
      <span>
        <span class="documents__collection-trigger__icon">
          <%= icon "folder-line" %>
          <%= icon "folder-open-line" %>
        </span>
        <%= decidim_escape_translated(attachment_collection.name) %>
      </span>

      <div class="card__list-metadata">
        <div><%= icon "file-text-line" %><%= t("decidim.documents", count: documents.count) %></div>
        <% sum = 0
           documents.each { |document| sum += document.file_size.to_i } %>
        <div><%= icon "scales-2-line" %><%= number_to_human_size(sum) %></div>
      </div>
    </div>

    <%= icon "arrow-down-s-fill" %>
    <%= icon "arrow-up-s-fill" %>
  </button>

  <div id="dropdown-menu-documents-<%= attachment_collection.id %>" class="documents__collection-content" aria-hidden="true">
    <% if (description = attachment_collection.description).present? %>
      <p><%= decidim_escape_translated(description) %></p>
    <% end %>

    <div class="documents__container">
      <% documents.each do |document| %>
        <%= render partial: "decidim/application/document", formats: [:html], locals: { document: } %>
      <% end %>
    </div>
  </div>
</div>
<% end %>
